package com.example.swagger3code.controller;

import com.example.swagger3code.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @author Yum
 * @version 1.0
 */
@Api(tags = "swagger类注解测试")
@RestController
@RequestMapping()
public class HelloWord {

    @GetMapping("/hello")
    public String hello() {
        return "Hello";
    }

    @PostMapping("/search")
    @ApiOperation("search方法注解")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "age",value = "年龄",required = true,paramType = "query"),
            @ApiImplicitParam(name = "name",value = "姓名",required = true,paramType = "query"),
    })
    public String search(@RequestParam Integer age,
                         @RequestParam String name) {
        return "年龄：" + age + "\t" + "姓名："+name;
    }

    @PostMapping("/add")
    @ApiOperation("添加用户")
    public User add(@RequestBody User user) {
        return user;
    }
}
